{% extends 'shop/base.html' %}

{% block title %}对话记录{% endblock %}

{% block content %}
<h1 class="mb-6 text-3xl">对话</h1>
<div class="grid grid-cols-5 gap-6">
    <div class="col-span-3 space-y-6">
        {% for message in conversation.messages.all %}
            <div class="p-6 flex {% if message.created_by == request.user %}bg-blue-100{% else %}bg-gray-100{% endif %} rounded-xl">
                <div>
                    <p class="mb-4"><strong>{{ message.created_by.username }}</strong> @ {{ message.created_at }}</p>
                    <p>{{ message.content }}</p>
                </div>
            </div>
        {% endfor %}
        <form method="post" action="." class="mt-6">
            {% csrf_token %}

            {{ form.as_p }}

            <button class="py-4 px-8 text-lg bg-teal-500 hover:bg-teal-700 rounded-xl text-white">发送</button>
        </form>
    </div>
    {% include 'conversation/include/item_div.html' with item=conversation.item %}
</div>
{% endblock %}